<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  
</body>
<script>
  const menus = [
  { 
    path: '/',
    key: '/',
    redirect: '/home',
    meta: { // 该路由不出现在左侧菜单栏
      hidden: true
    }
  },
  {
    path: '/home',
    key: '0-1',
    title: '系统首页',
  },
  {
    path: '/bannermanager',
    key: '0-2',
    title: '轮播图管理',
    redirect: '/bannermanager/list',
    children: [
      {
        path: '/bannermanager/list',
        key: '0-2-0',
        title: '轮播图列表',
      },
      {
        path: '/bannermanager/add',
        key: '0-2-1',
        title: '添加轮播图',
        meta: {
          hidden: true
        }
      }
    ]
  },
  {
    path: '/navigatormanager',
    key: '0-3',
    title: '快捷导航管理',
    redirect: '/navigatormanager/list',
    children: [
      {
        path: '/navigatormanager/list',
        key: '0-3-0',
        title: '导航列表',
      },
      {
        path: '/navigatormanager/category',
        key: '0-3-1',
        title: '导航分类',
      },
      {
        path: '/navigatormanager/hlist',
        key: '0-3-2',
        title: '首页导航',
      }
    ]
  },
  {
    path: '/hmanager',
    key: '0-4',
    title: '首页数据管理',
    redirect: '/hmanager/seckilllist',
    children: [
      {
        path: '/hmanager/seckilllist',
        key: '0-4-0',
        title: '首页秒杀列表',
      },
      {
        path: '/hmanager/recommentlist',
        key: '0-4-1',
        title: '首页推荐列表',
      }
    ]
  },
  {
    path: '/usermanager',
    key: '0-5',
    title: '用户管理',
    redirect: '/usermanager/list',
    children: [
      {
        path: '/usermanager/list',
        key: '0-5-0',
        title: '用户列表',
      },
      {
        path: '/usermanager/register',
        key: '0-5-1',
        title: '注册用户',
      },
      {
        path: '/usermanager/adminlist',
        key: '0-5-2',
        title: '管理员列表',
      },
    ]
  },
  {
    path: '/productmanager',
    key: '0-6',
    title: '商品管理',
    redirect: '/productmanager/list',
    children: [
      {
        path: '/productmanager/list',
        key: '0-6-0',
        title: '商品列表',
      },
      {
        path: '/productmanager/sortlist',
        key: '0-6-1',
        title: '筛选商品',
      },
    ]
  },
  {
    path: '/setting',
    key: '0-7',
    title: '设置',
    meta: { // 该路由不出现在左侧菜单栏
      hidden: true
    }
  }
]

const checkedkeys = ["0-2", "0-2-0", "0-2-1", "0-3-0", "0-3-1", '0-4-1'] 
const newArr = []
for (let item of checkedkeys) {
     newArr.push(item)
     const three = item.slice(0, 3)
     const idxT = newArr.indexOf(three);
     if (idxT < 0) {
         newArr.push(three)
     }   
}
console.log(1, newArr.sort())
//去重
const lastArr = Array.from(new Set(newArr))
console.log(lastArr.sort()) // ["0-2", "0-2-0", "0-2-1", "0-3", "0-3-0", "0-3-1"]

let someArr3 = menus.filter(info=>{
          return lastArr.some(item=>item === info.key)
      })


console.log(someArr3)
</script>
</html>